package com.kingsailor.gunsmith.security;

/**
 * @author xulixin
 */
public class UserAuthObjectServiceProxyBean implements UserAuthObjectService {

    private AppUserAuthObjectService appUserAuthObjectService;
    private final DummyUserAuthObjectServiceImpl dummyUserAuthObjectService;

    public UserAuthObjectServiceProxyBean() {
        this.dummyUserAuthObjectService = new DummyUserAuthObjectServiceImpl();
    }

    public void setAppUserAuthObjectService(AppUserAuthObjectService appUserAuthObjectService) {
        this.appUserAuthObjectService = appUserAuthObjectService;
    }

    @Override
    public BaseAppUser getBaseAppUserByUsername(String username) {
        return appUserAuthObjectService == null ? dummyUserAuthObjectService.getBaseAppUserByUsername(username)
                : appUserAuthObjectService.getBaseAppUserByUsername(username);
    }

    @Override
    public UserRolePermission getUserRolePermissionByUsername(String username) {
        return appUserAuthObjectService == null ? dummyUserAuthObjectService.getUserRolePermissionByUsername(username)
                : appUserAuthObjectService.getUserRolePermissionByUsername(username);
    }
}
